//
// Created by YangShuai on 2022/12/11.
//

/**
  ******************************************************************************
  * @file    task_remote.c
  * @author  XJTU ROBOMASTER Team
  * @brief   remote task
  * @priority osPriorityHigh
  *
  @verbatim
  ==============================================================================

  @endverbatim
  ******************************************************************************
  * @attention
  *
  * Please add comments after adding or deleting functions to ensure code
  * specification.
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "cmsis_os.h"
#include "bsp_usart.h"
#include "driver_remote.h"
#include "task_lostcounter.h"
#include "task_chassis.h"
#include "driver_gimbal.h"
/* Exported variables --------------------------------------------------------*/
extern osSemaphoreId_t RemoteSemHandle;
extern GimbalReceiveStruct GimbalReceive;
/* ----------------------- Function Implements ---------------------------- */

void RemoteTask(void* argument)
{
    for (;;)
    {
#if USE_REMOTE_DATA
        USART1ConfigEnable((uint8_t*)remote_Rx_Buffer, RC_FRAME_LENGTH);
        osStatus_t remoteStatus = osSemaphoreAcquire(RemoteSemHandle, 14);
        if (remoteStatus == osOK)
        {
            if (!RC_Update()) {
                LostCounterFeed(REMOTE_LOST_COUNT);
                GimbalReceive.LostCounter = 0;
            }
        }
#endif
        osDelay(1);
    }
}

/************************ (C) COPYRIGHT XJTU ROBOMASTER ********END OF FILE****/
